<extend name="Layout::index"/>
<block name="title"><title>放映场次管理</title></block>
<block name="content">
    <!--右内容区域-->
    <div class="layout-content">
        <!--<div class="top-nav" style="margin-left:72%;position: absolute;margin-top:2%;">-->
        <!--<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal4">添加影厅</button>-->
        <!--</div>-->
        <div class="page-title">放映场次管理</div>

        <div class="content-top">
            <ul class="top-nav">
                <li class="active"><span>放映场次列表</span></li>
            </ul>
            <div class="clearfix"></div>

        </div>
        <!--content-main end-->
        <div class="container-fluid content-main">
            <div class="row">
                <div class="col-md-12">
                    <div class="hidden ui-tips bg-info" id="error">
                        <span class=" icon glyphicon glyphicon-info-sign">d12121</span>
                    </div>
                    <!-- {$movies|dump} -->
                    <form class="form-horizontal" method="post" onsubmit="return false">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">ID</label>

                            <div class="col-sm-8">
                                <input type="text" name="id" class="form-control" value="{$data['id']}" id="id" readonly="readonly">
                                <span class="help-block"></span>
                            </div>
                        </div>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">电影</label>

                            <div class="col-sm-8">
                                <select class="form-control" id="name" name="name">
                                    <foreach name="movies" item="val">
                                    <option value="{$val['id']}" {$movie==$val['id']?'selected':''}>{$val['name']}</option>
                                    </foreach>
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">放映厅</label>

                            <div class="col-sm-8">
                                <select class="form-control" id="rnam" name="rnam">
                                    <foreach name="room" item="val" >
                                        <option value="{$val['id']}">{$val['name']}</option>
                                    </foreach>
                                </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">放映时间</label>
                            <div class="col-sm-8">
                                  <select name="timey" id="timey">
                                   <option value="2016">2016</option>
                               </select>
                               <select name="timem" id="timem">
                                   <for start="1" end="13">
                                   <option value="{$i}"  {$m==$i?'selected':''} >{$i}月</option>
                                   </for>
                               </select>
                               <select name="timed" id="timed">
                                   <for start="1" end="32">
                                   <option value="{$i}" {$d==$i?'selected':''}>{$i}日</option>
                                   </for>
                               </select>
                               <select name="timeh" id="timeh">
                                   <for start="1" end="25">
                                   <option value="{$i}" {$h==$i?'selected':''}>{$i}时</option>
                                   </for>
                               </select>
                               <select name="timei" id="timei">
                                   <for start="1" end="61">
                                   <option value="{$i}" {$mi==$i?'selected':''}>{$i}分</option>
                                   </for>
                               </select>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">单价</label>

                            <div class="col-sm-8">
                                <input type="text" name="cp" class="form-control" value="{$data['cp']}" id="cp">
                                <span class="help-block"></span>
                            </div>
                        </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-8">
                        <button class="btn btn-default" id="revise">保存</button>
                    </div>
                </div>
                </form>
            </div>
        </div>

    </div>
    </div>
    <!--右内容区域结束-->
</block>
<block name="script">
    <script>
         var room=$('#rnam option');     
         var r={$r};
         for (var i = 0; i <room.length; i++) {
               if($(room[i]).val()==r){
               //$(room[i]).addClass('selected');
               $(room[i]).attr("selected","selected");
            }
         };

        $('#revise').click(function () {
             //alert(1);
              var ctime=$('#timey').val()+'-'+$('#timem').val()+'-'+$('#timed').val()+'-'+$('#timeh').val()+'-'+$('#timei').val();
            $.ajax({
                url: "{:U('index/update')}",
                type: 'POST',
                data: {'id': $('#id').val(), 'movie_id': $('#name').val(), 'room_id': $('#rnam').val(),'showtime': ctime, 'price': $('#cp').val()},
                dataType: 'json',
                success: function (data) {
                       /*  if (data==1) {
          $('#error').attr('class', 'ui-tips bg-info').find('span').html('修改成功');
                         }else{
          $('#error').attr('class', 'ui-tips bg-info').find('span').html('未进行任何修改');
                 }*/
                    switch(data){
                        case 1:
         $('#error').attr('class', 'ui-tips bg-info').find('span').html('修改成功');
                            break;
                        case 2:
         $('#error').attr('class', 'ui-tips bg-info').find('span').html('未进行任何修改');
                            break;
                        case 3:
          $('#error').attr('class', 'ui-tips bg-info').find('span').html('价格不能为空哦');
                            break;
                    }
                }

             })
        })
    </script>
</block>
